//
//  NSString+Secrecy.m
//  WestWolves
//
//  Created by JL on 16/1/9.
//  Copyright © 2016年 ZJ. All rights reserved.
//

#import "NSString+Secrecy.h"
#import "NSString+Judge.h"

@implementation NSString (Secrecy)
-(NSString *)secrecyFrontWithNumBit:(int)num;
{
    if ([NSString isNull:self]) {
        return nil;
    }
    if (self.length>num) {
        NSMutableString *mStr=[[NSMutableString alloc] initWithString:self];
        for (int i=num; i<mStr.length; i++) {
            [mStr replaceCharactersInRange:NSMakeRange(i, 1) withString:@"*"];
        }
        return mStr;
    }
    return self;
}
-(NSString *)secrecyBehindWithNumBit:(int)num
{
    if ([NSString isNull:self]) {
        return nil;
    }
    if (self.length>num) {
        NSMutableString *mStr=[[NSMutableString alloc] initWithString:self];
        for (int i=0; i<mStr.length-num; i++) {
            [mStr replaceCharactersInRange:NSMakeRange(i, 1) withString:@"*"];
        }
        return mStr;
    }
    return self;
}
-(NSString *)secrecyMiddleWithFrontNumBit:(int)frontNum andBehindNumBit:(int)behindNum
{
    if ([NSString isNull:self]) {
        return nil;
    }
    if (self.length>(frontNum+behindNum)) {
        NSMutableString *mStr=[[NSMutableString alloc] initWithString:self];
        for (int i=frontNum; i<mStr.length-behindNum; i++) {
            [mStr replaceCharactersInRange:NSMakeRange(i, 1) withString:@"*"];
        }
        return mStr;
    }
    return self;
}

@end
